<!--
 * @Description: 
 * @Author: HYH
 * @LastEditors: HYH
 * @LastEditTime: 2023-05-26 23:56:45
-->
<template>
  <div class="flex-1 m-6 p-6 mx-0 bg-stone-200 rounded-xl overflow-auto">
    <ul class="menu bg-base-100 rounded-md m-4 w-auto" v-for="(item, index) in data" :key="index">
      <li class="menu-title !text-gray-800 py-1 !text-2xl font-bold">
        <a>{{ item.prefix?.split('/api/').pop() }}</a>
      </li>
      <li class="hover:bg-success rounded-none" v-for="(_, index) in item.stack" :key="index">
        <a>{{ _ }}</a>
      </li>
    </ul>
  </div>
</template>
<script setup lang="ts">
import { http } from '@/http'
const activeTab = ref('')
// interface IProps {
//   prefix: string
//   stack: string[]
// }
// defineProps<{ data: IProps[] }>()
const data = ref()
onMounted(() => {
  http.post<any>('/api/test').then(res => {
    const apiArr = []
    res.data.allRoutes.map((item: any) => {
      const {
        opts: { prefix }
      } = item
      const api = {
        prefix,
        stack: item.stack.map(item => item.path)
      }
      apiArr.push(api)
    })
    data.value = apiArr
    activeTab.value=apiArr[0].prefix
  })
})
</script>
